import 'package:flutter/material.dart';
import 'package:amap_location/amap_location.dart';
class LocationPage extends StatefulWidget {
  LocationPage({Key key}) : super(key: key);

  _LocationPageState createState() => _LocationPageState();
}

class _LocationPageState extends State<LocationPage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _getLocation();
  }
  _getLocation() async{
    AMapLocationClient.setApiKey("e3254c57a90c1e02410dab46a23260ac");
    // 启动下
    await AMapLocationClient.startup(new AMapLocationOption( desiredAccuracy:CLLocationAccuracy.kCLLocationAccuracyHundredMeters  ));
    // 获取地理位置信息
    var result = await AMapLocationClient.getLocation(true);
    print("11111" );
    print("经度：${result.longitude}" );
    print("纬度：${result.latitude}");

    // AMapLocationClient.onLocationUpate.listen((AMapLocation loc){
    //   if(!mounted)return;
       
    // });

    AMapLocationClient.startLocation();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("LocationPage"),
      ),
    );
  }
}